package com.mrfechetto.utils;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Configuration
{
   private static Properties config;
   
   public static String getProperty(String propertyName)
   {
      if(config == null)
      {
         config = new Properties();
         try
         {
            InputStream stream = ClassLoader.getSystemResourceAsStream("config/player.properties");
            if(stream == null)
            {
               stream = Configuration.class.getResourceAsStream("config/player.properties");
            }
            if(stream != null)
            {
               config.load(stream);
            }
            else
            {
               FileInputStream fileStream = new FileInputStream(System.getProperty("config/player.properties"));
               if(fileStream != null)
               {
                  config.load(fileStream);
               }
            }

         }
         catch(IOException e)
         {
            e.printStackTrace();
         }

      }
      
      return (String) config.get(propertyName);
   }
}
